<?php
require_once('Xml/Strategy/Abstract.php');

class Xml_Strategy_File extends Xml_Strategy_Abstract {
    const TIME_CACHE = '1 day';
    const ROOT_PATH = '/var/html';
    public function process(Xml_Abstract $_instance) {
       $fileName = $_instance->getFileName();
       $filePath = $_SERVER['DOCUMENT_ROOT'].'/'.$fileName;
       /*
       if (!file_exists($filePath)) {
           $fh = fopen($filePath, 'w+b');
           fwrite($fh, $_instance->getXml());
           clearstatcache();
       }*/
        $fh = fopen($filePath, 'w+b');
        fwrite($fh, $_instance->getXml());
        /*
       if (strtotime('-'.self::TIME_CACHE) > filemtime($filePath)) {
          file_put_contents($filePath, $_instance->getXml());
       }*/
       exit("write data  to :".$fileName);
       return $filePath;
    }
}
